import logging

from config import BASE_HOST


class TenderApi:

    def __init__(self, session):
        # 获取session对象
        self.ses = session

    # 投资接口
    def tender(self, tender_id, amount, dep=-1):
        form_dict = {"id": tender_id, "depositCertificate": dep, "amount": amount}
        resp = self.ses.post(url=BASE_HOST + "/trust/trust/tender", data=form_dict)
        logging.info("投资接口响应数据：{}".format(resp.json()))
        return resp

    # 第三方投资接口
    def third_tender(self,url, form_dict):
        resp = self.ses.post(url=url, data=form_dict)
        logging.info("第三方投资接口响应数据：{}".format(resp.text))
        return resp

